﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:MahApps.Metro.Controls">

    <Style TargetType="GroupBox"
           x:Key="CleanGroupBoxStyleKey">
        <Setter Property="BorderBrush"
                Value="{DynamicResource GrayBrush7}" />
        <Setter Property="BorderThickness"
                Value="0.3" />
        <Setter Property="Controls:ControlsHelper.HeaderFontSize"
                Value="16" />
        <Setter Property="Controls:GroupBoxHelper.HeaderForeground"
                Value="{DynamicResource TextBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="GroupBox">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <ContentPresenter Margin="{TemplateBinding Padding}"
                                          Content="{TemplateBinding Header}"
                                          ContentTemplate="{TemplateBinding HeaderTemplate}"
                                          ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                          ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                                          TextElement.Foreground="{TemplateBinding Controls:GroupBoxHelper.HeaderForeground}"
                                          TextElement.FontSize="{TemplateBinding Controls:ControlsHelper.HeaderFontSize}"
                                          TextElement.FontStretch="{TemplateBinding Controls:ControlsHelper.HeaderFontStretch}"
                                          TextElement.FontWeight="{TemplateBinding Controls:ControlsHelper.HeaderFontWeight}"
                                          RecognizesAccessKey="True"
                                          Grid.Row="0" />

                        <Grid VerticalAlignment="Stretch"
                              HorizontalAlignment="Stretch"
                              Grid.Row="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Grid.Resources>
                                <Style x:Key="InternalBorderStyle"
                                       TargetType="Border">
                                    <Setter Property="VerticalAlignment"
                                            Value="Stretch" />
                                    <Setter Property="Panel.ZIndex"
                                            Value="1" />
                                    <Setter Property="Width"
                                            Value="Auto" />
                                </Style>
                            </Grid.Resources>

                            <Border Grid.Column="0"
                                    Style="{StaticResource InternalBorderStyle}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    Background="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}" />

                            <ContentPresenter Grid.Column="1"
                                              Content="{TemplateBinding Content}"
                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                              Cursor="{TemplateBinding Cursor}" />

                            <Border Grid.Column="2"
                                    Style="{StaticResource InternalBorderStyle}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    Background="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}" />
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>